#ifndef _HTTPCONNECTION_H_
#define _HTTPCONNECTION_H_
#include<string>

#include"EpollLoop.h"
using std::string;

namespace http_server
{


class HttpConnection
{
public:
    HttpConnection(int fd, EpollLoop* loop);
    ~HttpConnection();
    void checkRequest();
    
private:
    void sendFile(const char* filename);
    void sendDir(const char* diename);
    string getFileType(string file);
    void sendRespond(int err, string title, string text, int size);
    void sendErr(int err, string title, string text);
    Address getLocal(int fd);
    Address getPeer(int fd);
    void disconnect();

private:
    EpollLoop* _event;
    Socket _sock;
    Address _serv;
    Address _clie;
    bool _shutdownflag;
    socketIO _sio;
};

} // namespace http_server

#endif